package net.comm.util;

import java.text.SimpleDateFormat;
import java.util.Date;

import net.comm.common.GlbFinal;

public class Ageutil {

    //生肖
    public static final String SHXIAO_SHU = "1";	//鼠    
    public static final String SHXIAO_NIU = "2";    //牛
    public static final String SHXIAO_HU = "3";    //虎
    public static final String SHXIAO_TU = "4";    //兔
    public static final String SHXIAO_LONG = "5";  //龙  
    public static final String SHXIAO_SHE = "6";   //蛇 
    public static final String SHXIAO_MA = "7";    //马
    public static final String SHXIAO_YANG = "8";  //羊  
    public static final String SHXIAO_HOU = "9";   //猴 
    public static final String SHXIAO_JI = "A";    //鸡
    public static final String SHXIAO_GOU = "B";   //狗 
    public static final String SHXIAO_ZHU = "C";   //猪 

    //星座
    public static final String STAR_SHUIPING = "1";	//水瓶座 
    public static final String STAR_SHUANGYU = "2";	//双鱼座   
    public static final String STAR_BAIYANG = "3";	//白羊座  
    public static final String STAR_JINNIU = "4";	//金牛座   
    public static final String STAR_SHUANGZI = "5";	//双子座  
    public static final String STAR_JUXIE = "6";	//巨蟹座
    public static final String STAR_SHIZI = "7";	//狮子座
    public static final String STAR_CHUNV = "8";	//处女座
    public static final String STAR_TIANCHENG = "9";	//天秤座    
    public static final String STAR_TIANXIE = "A";	//天蝎座
    public static final String STAR_SHESHOU = "B";	//射手座
    public static final String STAR_MOJIE = "C";	//摩羯座		
	
	/********************************************************
	  功    能：根据年份计算年龄
	  入口参数：param year:年份
	  出口参数：
	  返    回：年龄
	  整 理 人：
	  编写日期：20051220
	  修改备注：
	  ********************************************************/
	public static Integer age(int year) {
		  int age = 0;
		  Date date = new Date();
		  SimpleDateFormat sd = new SimpleDateFormat("yyyy");
		  age = Integer.parseInt(sd.format(date)) - year;
		  return age;
	 }
	
	/********************************************************
	  功    能：根据年份计算生肖
	  入口参数：param year:年份
	  出口参数：
	  返    回：生肖
	  整 理 人：
	  编写日期：20051220
	  修改备注：
	  ********************************************************/	
	public static String sxiao(int year) {
		  String sxiao = "";
		  int start = 1901;
		  int x = (start - year) % 12;
		  if (x == 1 || x == -11) {
		   sxiao = SHXIAO_SHU;		//"鼠";
		  }
		  if (x == 0) {
		   sxiao = SHXIAO_NIU;		//"牛";
		  }
		  if (x == 11 || x == -1) {
		   sxiao = SHXIAO_HU;		//"虎";
		  }
		  if (x == 10 || x == -2) {
		   sxiao = SHXIAO_TU;		//"兔";
		  }
		  if (x == 9 || x == -3) {
		   sxiao = SHXIAO_LONG;	//"龙";
		  }
		  if (x == 8 || x == -4) {
		   sxiao = SHXIAO_SHE;		//"蛇";
		  }
		  if (x == 7 || x == -5) {
		   sxiao = SHXIAO_MA;		//"马";
		  }
		  if (x == 6 || x == -6) {
		   sxiao = SHXIAO_YANG;	//"羊";
		  }
		  if (x == 5 || x == -7) {
		   sxiao = SHXIAO_HOU;		//"猴";
		  }
		  if (x == 4 || x == -8) {
		   sxiao = SHXIAO_JI;		//"鸡";
		  }
		  if (x == 3 || x == -9) {
		   sxiao = SHXIAO_GOU;		//"狗";
		  }
		  if (x == 2 || x == -10) {
		   sxiao = SHXIAO_ZHU;		//"猪";
		  }
		  return sxiao;
		 }
	
	/********************************************************
	  功    能：根据月日计算星座
	  入口参数：param month：月 day:日
	  出口参数：
	  返    回：星座
	  整 理 人：
	  编写日期：20051220
	  修改备注：
	  ********************************************************/		
	public static String star(int month, int day) {
			String star = "";
		  if (month == 1 && day >= 20 || month == 2 && day <= 18) {
		   star = STAR_SHUIPING;	//"水瓶座";
		  }

		  if (month == 2 && day >= 19 || month == 3 && day <= 20) {
		   star = STAR_SHUANGYU;	//"双鱼座";
		  }

		  if (month == 3 && day >= 21 || month == 4 && day <= 19) {
		   star = STAR_BAIYANG;	//"白羊座";
		  }

		  if (month == 4 && day >= 20 || month == 5 && day <= 20) {
		   star = STAR_JINNIU;		//"金牛座";
		  }

		  if (month == 5 && day >= 21 || month == 6 && day <= 21) {
		   star = STAR_SHUANGZI;	//"双子座";
		  }

		  if (month == 6 && day >= 22 || month == 7 && day <= 22) {
		   star = STAR_JUXIE;		//"巨蟹座";
		  }

		  if (month == 7 && day >= 23 || month == 8 && day <= 22) {
		   star = STAR_SHIZI;		//"狮子座";
		  }

		  if (month == 8 && day >= 23 || month == 9 && day <= 22) {
		   star = STAR_CHUNV;		//"处女座";
		  }

		  if (month == 9 && day >= 23 || month == 10 && day <= 22) {
		   star = STAR_TIANCHENG;	//"天秤座";
		  }

		  if (month == 10 && day >= 23 || month == 11 && day <= 21) {
		   star = STAR_TIANXIE;	//"天蝎座";
		  }

		  if (month == 11 && day >= 22 || month == 12 && day <= 21) {
		   star = STAR_SHESHOU;	//"射手座";
		  }

		  if (month == 12 && day >= 22 || month == 1 && day <= 19) {
		   star = STAR_MOJIE;		//"摩羯座";
		  }

		  return star;
	}

	
	
}
